package com.newworld.dmsapp2.activity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONObject;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.newworld.dmsapp2.BaseActivity;
import com.newworld.dmsapp2.R;
import com.newworld.dmsapp2.activity.designtask.SelectServerActivity;
import com.newworld.dmsapp2.activity.visit.VisitDetailActivity;
import com.newworld.dmsapp2.bean.InitOperation;
import com.newworld.dmsapp2.bean.InitProgressFunction;
import com.newworld.dmsapp2.bean.InitTaskState;
import com.newworld.dmsapp2.bean.Task;
import com.newworld.dmsapp2.bean.User;
import com.newworld.dmsapp2.fragment.bean.InitPhotoVoiceItemEntity;
import com.newworld.dmsapp2.fragment.bean.InitPhotoVoiceItemEntityServe;
import com.newworld.dmsapp2.fragment.bean.InitTextItemEntity;
import com.newworld.dmsapp2.ui.view.CustomButtonItem;
import com.newworld.dmsapp2.ui.view.CustomDialog;
import com.newworld.dmsapp2.ui.view.CustomLoadingDialog;
import com.newworld.dmsapp2.ui.view.CustomPhotoVoiceItem;
import com.newworld.dmsapp2.ui.view.CustomTextItem;
import com.newworld.dmsapp2.util.Config;
import com.newworld.dmsapp2.util.HttpUtil;
import com.newworld.dmsapp2.util.InitFunctionUtil;
import com.newworld.dmsapp2.util.InitViewUtil;
import com.newworld.dmsapp2.util.SingleSample;
import com.newworld.dmsapp2.util.StringUtil;
import com.newworld.dmsapp2.util.Tool;

public class DoubleDetailActivity extends BaseActivity implements
		OnClickListener {

	private TextView titleCenterTv;
	private LinearLayout leftLinLayout;
	private LinearLayout mainLayout, uponLayout, pointLayout;
	private CustomLoadingDialog uploadingdialog;
	private ProgressBar loginbar;

	private Intent intent;
	private Bundle bundle;
	private String sessionId;
	private User user;
	private Task task;
	private List<InitProgressFunction> initProgressFunctions = new ArrayList<InitProgressFunction>();
	private static InitTaskState initTS = new InitTaskState();
	private static InitProgressFunction initPF = new InitProgressFunction();
	private static List<InitOperation> initOPs = new ArrayList<InitOperation>();
	private static InitOperation initOP = new InitOperation();
	private List<InitTextItemEntity> titletextItemList = new ArrayList<InitTextItemEntity>();
	private List<InitTextItemEntity> reporttextItemList = new ArrayList<InitTextItemEntity>();
	private List<InitTextItemEntity> repairtextItemList = new ArrayList<InitTextItemEntity>();

	private boolean isReporter;
	private String peopleType;
	private String listRealFunctionCode;
	private String operationFunctionCode;
	private String operationName;
	private String repairId;
	private String message;
	private String houseFullName;
	

	static CustomButtonItem cusbuttonItem;

	Handler mHandler = new Handler() {
		@SuppressLint("NewApi")
		@Override
		public void handleMessage(Message msg) {
			// TODO Auto-generated method stub
			Bundle b = new Bundle();
			Intent i = new Intent();
			switch (msg.what) {
			case Config.HANDLER_MSG_SUCCESS:
				addViews();
				Toast.makeText(DoubleDetailActivity.this, message,
						Toast.LENGTH_SHORT);
				loginbar.setVisibility(View.INVISIBLE);
				break;
			case Config.HANDLER_MSG_OPERATION_SUCCESS:
				if (uploadingdialog.isShowing()) {
					uploadingdialog.dismiss();
				} else {
					uploadingdialog.show();
				}
			
			if(StringUtil.isStringContaind(initOP.getOperationName(), "上报")){
				if(user.isTaskExistByRepairId(repairId)){
					if(user.deleteTaskByRepairId(repairId)){
						Log.e("完成维修删除任务", repairId + "删除成功");
					}else{
						Log.e("完成维修删除任务", repairId + "删除失败");
					}
					
				}
			}else if(StringUtil.isStringContaind(initOP.getOperationName(), "完成维修")){
				changeLocalTask();
			}
				finish();

				Toast.makeText(DoubleDetailActivity.this, message,
						Toast.LENGTH_SHORT);
				break;
			case Config.HANDLER_MSG_FAIL:
				if (uploadingdialog.isShowing()) {
					uploadingdialog.dismiss();
				} else {
					uploadingdialog.show();
				}
				loginbar.setVisibility(android.view.View.INVISIBLE);
				Toast.makeText(DoubleDetailActivity.this, message,
						Toast.LENGTH_SHORT);
				break;

			default:
				break;
			}
			super.handleMessage(msg);
		}
	};

	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_double_detail);
		initData();
		initViews();
		initEvents();
		if(!user.isTaskExistByRepairId(repairId)){
			if (Tool.isNetworkAvailable(DoubleDetailActivity.this)) {
				loginbar.setVisibility(View.VISIBLE);
				new Thread(getDataRun).start();
			} else {
				Toast.makeText(this, "请设置网络", Toast.LENGTH_SHORT).show();

			}
		}else{
			addViews();
		}
		
	}

	private void initData() {
		intent = getIntent();
		bundle = intent.getExtras();
		user = SingleSample.getInstance(this).getUser();
		if (null != user) {
			if (null != user.getSessionId() && !user.getSessionId().equals("")) {
				sessionId = user.getSessionId();
			}
		}

		initTS = (InitTaskState) bundle.getSerializable(Config.INITTASTSTATE);
		initPF = (InitProgressFunction) bundle
				.getSerializable(Config.INITPROGRESSFUNCTION);
		initOPs = Tool.getInitOperationOfPage(initTS, 2);
		task = (Task) bundle.getSerializable(Config.TASK);
		repairId = task.getRepairId();
		isReporter = bundle.getBoolean(Config.ISREPORTER);
		peopleType = bundle.getString(Config.PEOPLETYPE);
		houseFullName = bundle.getString(Config.HOUSEFULLNAME);
		listRealFunctionCode = bundle.getString(Config.FUNCTIONCODE);
		InitFunctionUtil functionUtil = new InitFunctionUtil(this);
		initProgressFunctions = functionUtil.getProgressFunction();
		System.out.println("报修位置"+houseFullName);
		titletextItemList = InitViewUtil.getDoubleTitleTextItemContent(task,houseFullName,
				initTS);
		reporttextItemList = InitViewUtil.getDoubleReportPointTextItemContent(
				task, initTS);
		repairtextItemList = InitViewUtil.getDoubleRepairPointTextItemContent(
				task, initTS);
	}

	@Override
	protected void initViews() {
		// TODO Auto-generated method stub
		titleCenterTv = (TextView) findViewById(R.id.titlebar_left_center_title);
		leftLinLayout = (LinearLayout) findViewById(R.id.titlebar_left_left_layout);
		mainLayout = (LinearLayout) findViewById(R.id.double_detail_ly);
		uponLayout = (LinearLayout) findViewById(R.id.double_detail_uponly);
		pointLayout = (LinearLayout) findViewById(R.id.double_detail_belowly);
		loginbar = (ProgressBar) findViewById(R.id.double_detail_progressBar);
	}

	/**
	 * 动态布局
	 */
	private void addViews() {
		titleCenterTv.setText("双节点界面");
		addTitleDetailView();
		addReportPointDetailView();
		addSeperateLine();
		addRepairPointDetailView();
		addButtonView();

	}

	/**
	 * 抬头文本初始化
	 */
	private void addTitleDetailView() {
		LinearLayout.LayoutParams LP_FW = new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);

		for (InitTextItemEntity te : titletextItemList) {
			CustomTextItem cutextItem = new CustomTextItem(this);
			LinearLayout textItem = cutextItem.getCustomTextItem(this, te,
					task, 0);
			uponLayout.addView(textItem, LP_FW);
		}
	}

	/**
	 * 报修节点控件初始化
	 */
	private void addReportPointDetailView() {

		LinearLayout.LayoutParams LP_FW = new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
		// 文本信息显示
		for (InitTextItemEntity te : reporttextItemList) {
			CustomTextItem cutextItem = new CustomTextItem(this);
			LinearLayout textItem = cutextItem.getCustomTextItem(this, te,
					task, 1);
			pointLayout.addView(textItem, LP_FW);
		}

		// 图片 、录音显示
		InitPhotoVoiceItemEntity photoVoiceEntity = new InitPhotoVoiceItemEntity();
		photoVoiceEntity.setImagePath1(task.getProblemImage1());
		photoVoiceEntity.setImagePath2(task.getProblemImage2());
		photoVoiceEntity.setVoicePath(task.getProblemVoice());
		//photoVoiceEntity.setVoiceTime(task.getProblenmVoiceTime());
		photoVoiceEntity.setChangeView(false);// 不可编辑图片、录音
		CustomPhotoVoiceItem cuPhotoVoiceItem = new CustomPhotoVoiceItem(this);
		LinearLayout photoVoiceItem = cuPhotoVoiceItem.getCustomPhotoVoiceItem(
				this, photoVoiceEntity,false);
		pointLayout.addView(photoVoiceItem, LP_FW);
		
	}

	/**
	 * 维修节点控件初始化
	 */
	private void addRepairPointDetailView() {
		InitPhotoVoiceItemEntityServe photoVoiceEntity = new InitPhotoVoiceItemEntityServe();
		LinearLayout.LayoutParams LP_FW = new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
		// 文本信息显示
		for (InitTextItemEntity te : repairtextItemList) {
			CustomTextItem cutextItem = new CustomTextItem(this);
			LinearLayout textItem = cutextItem.getCustomTextItem(this, te,
					task, 1);
			pointLayout.addView(textItem, LP_FW);
		}

		// 图片 、录音显示
		photoVoiceEntity.setImagePathS1(task.getSolvedImage1());
		photoVoiceEntity.setImagePathS2(task.getSolvedImage2());
		photoVoiceEntity.setVoicePathS(task.getSolvedVoice());
		photoVoiceEntity.setVoiceTimeS(task.getSolvedVoiceTime());
		photoVoiceEntity.setChangeViewS(true);// 可编辑图片、录音
		CustomPhotoVoiceItem cuPhotoVoiceItem = new CustomPhotoVoiceItem(this);
		LinearLayout photoVoiceItem = cuPhotoVoiceItem.getCustomPhotoVoiceItem(
				this, photoVoiceEntity,true);
		pointLayout.addView(photoVoiceItem, LP_FW);
	}

	/**
	 * 底部按钮初始化
	 */
	private void addButtonView() {
		LinearLayout.LayoutParams LP_FW = new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
		// 按钮显示
		cusbuttonItem = new CustomButtonItem(this);
		LinearLayout buttonItem = cusbuttonItem.getCustomButtonItem(this,
				initOPs,false);
		Log.e("双节点的按钮个数是initOPs.size()", initOPs.size()+"");
		mainLayout.addView(buttonItem, LP_FW);
		if (null != initOPs) {
			switch (initOPs.size()) {
			case 1:
				cusbuttonItem.setButtonOnClick(btnListener0);
				break;
			case 2:
				cusbuttonItem.setButtonOnClick(btnListener0, btnListener1);
				break;
			case 3:
				cusbuttonItem.setButtonOnClick(btnListener0, btnListener1,
						btnListener2);
				break;
			default:
				break;
			}

		}
	}
	
	/**
	 * 添加分隔线
	 */
	private void addSeperateLine(){
		  
		  LinearLayout.LayoutParams LP_FW = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.MATCH_PARENT,
					LinearLayout.LayoutParams.WRAP_CONTENT);
			
			TextView lineText = new TextView(this);
			lineText.setBackgroundColor(getResources().getColor(R.color.nw_tl_bg_gray));
			lineText.setHeight(2);
			pointLayout.addView(lineText, LP_FW);
		  
	}

	OnClickListener btnListener0 = new OnClickListener() {

		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			btnClickEvent(0);
		}
	};

	OnClickListener btnListener1 = new OnClickListener() {

		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			btnClickEvent(1);
		}
	};

	OnClickListener btnListener2 = new OnClickListener() {

		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			btnClickEvent(2);
		}
	};

	private void btnClickEvent(int position) {
		initOP = initOPs.get(position);
		operationFunctionCode = initOP.getFunctionCode();
		operationName = initOP.getOperationName();
		Bundle b = new Bundle();
		Toast.makeText(DoubleDetailActivity.this, operationName,
				Toast.LENGTH_SHORT).show();
		if (operationName.contains("分配")
				|| (operationName.contains("派") && !operationName
						.equals("申请改派"))) {// 各种派单、改派操作
			b.putSerializable(Config.TASK, task);
			b.putSerializable(Config.PEOPLETYPE, peopleType);
			b.putSerializable(Config.INITOPERATION, initOP);
			intent = new Intent(DoubleDetailActivity.this,
					SelectServerActivity.class);
			intent.putExtras(b);
			startActivityForResult(intent, 0);
			finish();
		}if (operationName.contains("评价")) {// 评价
			b.putSerializable(Config.TASK, task);
			b.putSerializable(Config.PEOPLETYPE, peopleType);
			b.putSerializable(Config.INITOPERATION, initOP);
			Intent intent = new Intent(
					DoubleDetailActivity.this,
					ServiceScheduleUserValueActivity.class);
			intent.putExtras(b);
			startActivity(intent);
			finish();
		}if (operationName.contains("回访")) {// 回访、终止回访
			b.putSerializable(Config.TASK, task);
			b.putSerializable(Config.INITOPERATION, initOP);
			Intent intent = new Intent(
					DoubleDetailActivity.this,
					VisitDetailActivity.class);
			intent.putExtras(b);
			startActivity(intent);
			finish();
		} else {// 直接与服务器交互的操作
				// 标准的对话框封装
			final CustomDialog dialog2 = new CustomDialog(
					DoubleDetailActivity.this);

			dialog2.setTitle(operationName);
			dialog2.setDetial("是否要" + operationName + "？");
			dialog2.setLeftOnClick(new OnClickListener() {
				@Override
				public void onClick(View v) {
					dialog2.dismiss();
				}
			});
			dialog2.show();
			dialog2.setRightOnClick(new OnClickListener() {
				@Override
				public void onClick(View v) {
					dialog2.dismiss();
					uploadingdialog = new CustomLoadingDialog(
							DoubleDetailActivity.this, operationName + "...");
					if (uploadingdialog.isShowing()) {
						uploadingdialog.dismiss();
					} else {
						uploadingdialog.show();
					}
					if (Tool.isNetworkAvailable(DoubleDetailActivity.this)) {
						loginbar.setVisibility(View.VISIBLE);
						new Thread(postOperationRun).start();
					} else {
						Toast.makeText(DoubleDetailActivity.this, "请设置网络",
								Toast.LENGTH_SHORT).show();

					}

				}
			});
			dialog2.show();
		}

	}

	@Override
	protected void initEvents() {
		// TODO Auto-generated method stub
		leftLinLayout.setOnClickListener(this);

	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.titlebar_left_left_layout:
			// TODO Auto-generated method stub
			finish();
			break;

		default:
			break;
		}
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) { // 监控/拦截/屏蔽返回键

			finish();
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

	/**
	 * 获取详情界面数据
	 */
	Runnable getDataRun = new Runnable() {

		@Override
		public void run() {
			// TODO Auto-generated method stub
			try {
				String url = Tool.getUrlFromUrl(user,
						initPF.getProgressFunction());
				String result = null;
				String getDetailFunctionCode = Tool
						.getDetailFunctionCode(initPF.getProgressFunction());
				Map<String, String> map = new HashMap<String, String>();
				Log.e("getdata>>functioncode", getDetailFunctionCode);
				map.put("functionCode", getDetailFunctionCode);
				map.put("repairId", repairId);
				Log.e("repairId---222", repairId);

				result = HttpUtil.postRequestSe(url, map, sessionId);
				Log.e("任务想情的result1", result);
				String total = new JSONObject(result).getString("total");
				message = new JSONObject(result).getString("message");
				String flag = new JSONObject(result).getString("flag");
				String rows = new JSONObject(result).getString("rows");

				if (total.equals("0")) {
					mHandler.obtainMessage(Config.HANDLER_MSG_GETTASK_FAIL,
							"该任务不存在!").sendToTarget();
				} else {
					java.lang.reflect.Type type = new TypeToken<Task>() {
					}.getType();
					Gson gson = new Gson();
					JSONArray jsonArray = new JSONArray(rows);
					JSONObject jsonObject = jsonArray.getJSONObject(0);
					task = gson.fromJson(jsonObject.toString(), type);
					Log.e("task", task.getSolvedDescript() + "");
					task = Tool.setTaskAll(initProgressFunctions,
							listRealFunctionCode, peopleType, task, user);
					isReporter = Tool.isReporter(task, user.getUserId(),
							peopleType);
					if (flag.equals(Config.CONNECT_SUCCESS2)) {
						boolean flagb = false;
						String urlstr = Config.SERVER_URL
								+ user.getFunctionlistFromUser(
										Config.FUNCTION_REAL_DOWNLOADREPAIRFILE)
										.get(0).getFunctionUrl();
						map.put("sessionId", sessionId);
						map.put("functionCode",
								Config.FUNCTION_REAL_DOWNLOADREPAIRFILE);
						if (StringUtil.isStringAvailable(task
								.getProblemImage1())) {
							map.put("fileName", task.getProblemImage1());
							flagb = UploadService.downFile(urlstr,
									Config.IMAGE_PATH, map);
						}
						if (StringUtil.isStringAvailable(task
								.getProblemImage2())) {
							map.put("fileName", task.getProblemImage2());
							flagb = UploadService.downFile(urlstr,
									Config.IMAGE_PATH, map);
						}
						if (StringUtil
								.isStringAvailable(task.getProblemVoice())) {
							map.put("fileName", task.getProblemVoice());
							flagb = UploadService.downFile(urlstr,
									Config.VOICE_PATH, map);
						}
						if (StringUtil
								.isStringAvailable(task.getSolvedImage1())) {
							map.put("fileName", task.getSolvedImage1());
							flagb = UploadService.downFile(urlstr,
									Config.IMAGE_PATH, map);
						}
						if (StringUtil
								.isStringAvailable(task.getSolvedImage2())) {
							map.put("fileName", task.getSolvedImage2());
							flagb = UploadService.downFile(urlstr,
									Config.IMAGE_PATH, map);
						}
						if (StringUtil.isStringAvailable(task.getSolvedVoice())) {
							map.put("fileName", task.getSolvedVoice());
							flagb = UploadService.downFile(urlstr,
									Config.VOICE_PATH, map);
						}
						if (flagb) {
							mHandler.obtainMessage(Config.HANDLER_MSG_SUCCESS,
									message).sendToTarget();// 通知主线程数据发送成功
						} else {
							mHandler.obtainMessage(Config.HANDLER_MSG_SUCCESS,
									message).sendToTarget();// 通知主线程数据发送成功

						}
					} else {

						mHandler.obtainMessage(Config.HANDLER_MSG_FAIL, message)
								.sendToTarget();// 通知主线程数据发送成功
					}

				}
			} catch (Exception e) {
				Log.e("ServiceScheduleActivity", "json数据获取报错");
				message = "json解析出错";
				mHandler.obtainMessage(Config.HANDLER_MSG_FAIL, message)
						.sendToTarget();
				e.printStackTrace();
			}

		}
	};

	/**
	 * 按钮操作与服务器交互线程
	 */
	Runnable postOperationRun = new Runnable() {

		@Override
		public void run() {
			// TODO Auto-generated method stub

			try {
				String result = null;
				Map<String, String> map = new HashMap<String, String>();
				Log.e(operationName + "functionCode", operationFunctionCode);
				String url = Tool.getUrlFromUrl(user, operationFunctionCode);
				map.put("functionCode", operationFunctionCode);
				map.put("repairId", repairId);
				result = HttpUtil.postRequestSe(url, map, sessionId);
				Log.e(operationName + "result", result);
				message = new JSONObject(result).getString("message");
				String flag = new JSONObject(result).getString("flag");
				if (flag.equals(Config.CONNECT_SUCCESS2)) {
					mHandler.obtainMessage(
							Config.HANDLER_MSG_OPERATION_SUCCESS, message)
							.sendToTarget();// 通知主线程数据发送成功

				} else {
					mHandler.obtainMessage(Config.HANDLER_MSG_FAIL, message)
							.sendToTarget();
				}

			} catch (Exception e) {
				message = "json数据获取出错";
				mHandler.obtainMessage(Config.HANDLER_MSG_FAIL, message)
						.sendToTarget();

				e.printStackTrace();
			}
		}
	};

	
	/**
	 * 修改本地保存维修任务
	 */
	private void changeLocalTask() {
		if (task.getStatusType_typeCode().equals(
				Config.TYPECODE_SERVE)) {
			task.setTaskState(Config.TASKSTATE_TODO); // 待处理
		} else if (task.getStatusType_typeCode().equals(
				Config.TYPECODE_REMINDE)) {
			task.setTaskState(Config.TASKSTATE_BEASKED);// 被催单
		}
		Task localtask = user.getTasksByRepairId(repairId).get(0);
		long taskid = localtask.getId();
		Task savetask = new Task();
		task.setStopflag(true);
		task.setSolvedDescript(localtask.getSolvedDescript());
		task.setSolvedImage1(localtask.getSolvedImage1());
		task.setSolvedImage2(localtask.getSolvedImage2());
		task.setSolvedVoice(localtask.getSolvedVoice());
		//task.setSolvedVoiceTime(localtask.getSolvedVoiceTime());
		savetask = task;
		savetask.setUser(user);
		savetask.save();
		user.update(user.getId());
		if(user.deleteTaskByTaskId(taskid)){
			Log.e("停止维修","repairId任务更新成功");
		}else{
			Log.e("停止维修","repairId任务更新失败");
		}
	}
	
	/*private Runnable saveDataRun = new Runnable() {
		public void run() {
			saveData();
			if (Tool.isNetworkAvailable(DoubleDetailActivity.this)) {
				mHandler.obtainMessage(Config.HANDLER_MSG_LOACALSAVE_SUCCESS,
						"保存成功").sendToTarget();
			} else {
				mHandler.obtainMessage(Config.HANDLER_MSG_FAIL, "请设置网络")
						.sendToTarget();
			}

		}
	};*/


	/*private void saveData() {
		task.setSolvedImage1(solveimagePath1);
		task.setSolvedImage2(solveimagePath2);
		task.setSolvedVoice(solvevoicePath);
		task.setSolvedVoiceTime(voiceTime + "");
		task.setSolvedDescript(accomplish_servicedescribe.getText().toString());
		if (task.getStatusType_typeCode().equals(Config.TYPECODE_REMINDE)) {
			task.setTaskState(Config.TASKSTATE_BEASKED);
		} else {
			task.setTaskState(Config.TASKSTATE_TOPOST);
		}
		task.setStopflag(false);
		task.setMoreflag(true);
		task.setUser(user);
		task.update(task.getId());
		user.update(user.getId());
	}*/
}
